import { addClickFn } from ".";
import { VIEW_TYPE } from '../../constants/viewType'
import Editor from '../../editor'

let currentType:String = 'SOURCE'
export default function otherInput(editor:Editor){
    const inputs = document.getElementsByTagName('input')
    addClickFn(inputs,(target:HTMLElement) =>{
        switch(target.id){
            /**所见即所得 */
            case VIEW_TYPE.SOURCE:
                if(currentType !== VIEW_TYPE.SOURCE){
                    currentType = VIEW_TYPE.SOURCE
                    editor.getViewProvider().provide(VIEW_TYPE.SOURCE,editor.getTextModel(), editor.getSelectionModel(), editor.getContainer())
                }else{
                    return
                }
                
            break;
            /**双屏渲染 */
            case VIEW_TYPE.SOURCE_AND_PREVIEW:
                if(currentType !== VIEW_TYPE.SOURCE_AND_PREVIEW){
                    currentType = VIEW_TYPE.SOURCE_AND_PREVIEW
                    editor.getViewProvider().provide(VIEW_TYPE.SOURCE_AND_PREVIEW,editor.getTextModel(), editor.getSelectionModel(), editor.getContainer())
                }else{
                    return
                }     
               
            break;
        }

    })
}
